/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/



#if !defined(AFX_PGLGRAPHVIEW_H__D2A5BBE5_2C7A_41A6_8F22_9959D09CD057__INCLUDED_)
#define AFX_PGLGRAPHVIEW_H__D2A5BBE5_2C7A_41A6_8F22_9959D09CD057__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <pgl/core/PGLRegion.h>
#include <pgl/mfc/PGLMouse.h>
#include <pgl/mfc/PGLEvent.h>

/////////////////////////////////////////////////////////////////////////////
// CPGLView view

/*! \brief A CView derived class

  \ingroup PGLMFCGroup
*/
class PGLMFC_EXT_CLASS CPGLView : public CView
{
DECLARE_DYNCREATE(CPGLView)
protected:
	//! \name Constructors
	//@{
	//! protected constructor used by dynamic creation
	CPGLView();
	//@}

// Attributes
public:

// Operations
public:
	//! \name Flags
	//@{
	//! Enables/disables automatic scaling on OnInitialUpdate
	void SetInitialAutoScale(bool on = true)	{	m_bInitAutoScale = on;};
	//@}

	//! \name Getters
	//@{
	//! Sets the CPGLGraph object to plot on view 
	void SetRegion(CPGLRegionPtr pRegion);
	//! Returns pointer to the current region
	CPGLRegionPtr GetRegion()					{	return m_pRegion;};
	//! Destroy region
	void DestroyRegion()						{	m_pRegion.reset();};
	//! Return reference to GDI+ interface
	gfxinterface::CGfxInterface& GetGfxInterface()					{	return m_GDIpInterface;};
	//! Return reference to GDI+ interface, const
	const gfxinterface::CGfxInterface& GetGfxInterface()	const	{	return m_GDIpInterface;};
	//! returns reference to GDI+ helper
	pgl::CGDIpHelperRegion& GetGDIpHelper()				{	return m_GDIpHelper;};
	//! returns reference to GDI+ helper, const
	const pgl::CGDIpHelperRegion& GetGDIpHelper() const	{	return m_GDIpHelper;};
	//@}

	//! \name Resizing state
	//@{
	//! The view has been resized, and the charts have to be refreshed
	void PostResize()					{	m_bPostResize = true;};
	//! return true if refreshing is needed (used internally)
	bool IsResizeNeeded()				{	return m_bPostResize;};
	//! reset resize bit
	void ResetResizeState()				{	m_bPostResize = false;};
	//@}

	//! \name Redrawing
	//@{
	//! enables disables triple buffering
	void SetTripleBuffering(bool on = true);
	//! Makes rebuilding memory bitmap and redrawing the chart
	void SetDirty();
	//! Makes rebuilding memory bitmap and redrawing the chart
	void SetFrontDirty();
	//! Makes blitting of memory bitmap
	void SetCacheDirty();
	//@}

	//! \name Event
	//@{
	void SetEvent( CPGLEventPtr pEvent);
	CPGLEventPtr GetEvent()								{	return m_pEvent;};
	const CPGLEventPtr GetEvent()	const				{	return m_pEvent;};
	void ClearEvent();
	//@}

	//! \name Clipboard
	//@{
	//! Sets clipboard type
	void SetClipboardType(CPGLArchive::EClipBoardType eClipboardType)	{	m_eClipboardType = eClipboardType;};
	//! returns clipboard type
	CPGLArchive::EClipBoardType GetClipboardType() const				{	return m_eClipboardType;};
	//@}

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPGLView)
	public:
	virtual void OnInitialUpdate();
	protected:
	virtual void OnDraw(CDC* pDC);      // overridden to draw this view
	virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
	//}}AFX_VIRTUAL

		//! \name Serialization and debugging
	//@{
	//! Serialization
	virtual void SeralizeSettingsXML(CPGLArchive& ar);
// Implementation
protected:
	virtual ~CPGLView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif
	//@}

	// Generated message map functions
protected:
	CPGLMouse m_mouse;
	CPGLRegionPtr m_pRegion;
	UINT m_uPointedRegion;
	CPGLEventPtr m_pEvent;

	bool m_bPostResize;
	bool m_bInitAutoScale;
	gfxinterface::CGDIpInterface m_GDIpInterface;
	pgl::CGDIpHelperRegion m_GDIpHelper;
	CPGLArchive::EClipBoardType m_eClipboardType;

	//{{AFX_MSG(CPGLView)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnDestroy();
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnEditCopy();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_PGLGRAPHVIEW_H__D2A5BBE5_2C7A_41A6_8F22_9959D09CD057__INCLUDED_)
